package com.golxen.framework.common.server.cross.cmd.sync;


import com.golxen.framework.CrossProtocol;
import com.golxen.framework.GameProtocol;
import com.golxen.framework.PBPacket.PBPacket;
import com.golxen.framework.common.server.cross.cmd.AbstractCrossCommand;
import com.golxen.framework.netty.session.cross.CrossAgentLinkedSet;
import com.golxen.framework.common.server.game.cmd.Cmd;
import com.golxen.protojava.SyncMessage;
import com.google.protobuf.Message;

@Cmd(code = CrossProtocol.C_SERVICE_BACK_MESSAGE, desc = "跨服转发游戏服返回游戏服的非阻塞同步消息")
public class SyncBackMessageCmd extends AbstractCrossCommand {

	private SyncMessage.Response response;

    @Override
    public Message parseData(PBPacket packet) throws Exception {
        this.response = SyncMessage.Response.parseFrom(packet.getBytes());
        return response;
    }

    @Override
    public void execute(PBPacket packet) throws Exception {
        if (this.response.hasForwardServerId()) {
            if (this.response.getForwardServerId() > 0) {
                packet.setCode(GameProtocol.S_CROSS_SERVICE_MESSAGE_RESP);
                CrossAgentLinkedSet.send(this.response.getForwardServerId(), packet.getPlayerId(), packet);
            }
        }
    }

    @Override
    public void sendData() {

    }
}
